home *** CD-ROM | disk | FTP | other *** search
/ Aminet 37 / Aminet 37 (2000)(Schatztruhe)[!][Jun 2000].iso / Aminet / dev / misc / TCS.lha / TCS / examples / sources / XPfld.s < prev   
Text File  |  2000-04-13  |  11KB  |  306 lines

  1. *******************************************************************************
  2. * (Dual) Cross Playfield example
  3. *******************************************************************************
  4. * INFO    loads three 320x256x8 ILBMs and applies some (cross-)fading
  5. *    effects in (Dual) Cross Playfield mode
  6. * NOTE    - optionally you can pass as CLI argument the names of the
  7. *      320x256x8 IFF/ILBMs to load (if not one of those supplied in
  8. *      TCS/examples/pix/, make sure that yours is exactly 320x256x8
  9. *      and that it respects all the restrictions of TCS_LdILBM(),
  10. *      otherwise the program won't execute or the graphics will
  11. *      look bad - not dangerous, anyway!)
  12. *    - press LMB to quickly skip ahead
  13. *    - hold LMB down to exit anytime
  14. *******************************************************************************
  15.  
  16.     machine    68020
  17.  
  18.     include    INCLUDES:libraries/tcs.i
  19.     include    INCLUDES:libraries/tcs_lib.i
  20.  
  21.  
  22.  
  23. *******************************************************************************
  24. * definitions
  25. *******************************************************************************
  26.  
  27. DSPLWD    =    320    ;our TCS display width and
  28. DSPLHT    =    256    ;height in 140 ns pixels
  29. SCRWD    =    320    ;TCS screen width and
  30. SCRHT    =    256    ;height in pixels
  31. DSPLX0    =    $81*4    ;display start
  32. DSPLY0    =    $2c    ;position (SHRES pixels)
  33. DSPLX1    =    DSPLX0+DSPLWD*4    ;display end
  34. DSPLY1    =    DSPLY0+DSPLHT    ;position (SHRES pixels)
  35. DSPLBRTNS    =    256    ;max brightness
  36. GFXCTXT    =    0
  37. CWBTM    =    0
  38. CWTOP    =    0
  39. CWRT    =    0
  40. CWLF    =    0
  41. VDOMODE    =    TCS_VM_RGBW | TCS_VMf_FullRes
  42.  
  43. ARGSNO    =    3    ;command line arguments no.
  44.  
  45.  
  46.  
  47. *******************************************************************************
  48. * code start
  49. *******************************************************************************
  50.  
  51.     include    /includes/macros.i
  52.     include    /includes/shl_strtup.i
  53.  
  54.  
  55.  
  56. *******************************************************************************
  57. * init
  58. *******************************************************************************
  59.  
  60. _PrgInit    lea.l    DsplDef,a0    ;use same DD structure to
  61.     ori.l    #TCS_VMf_FPfld,(TCS_DD_VdoMode,a0) ;init another display
  62.     CALLTCS    InitDspl    ;for the front playfield
  63.     move.l    d0,FPfldDI    ;store DI structure address
  64.     beq.s    .fail    ;if error...
  65.  
  66. *******************************************************************************
  67. * back playfield
  68.  
  69.     movea.l    CmdLnArgs,a0    ;ILBM0 filename address
  70.     tst.l    a0
  71.     bne.s    .ld0    ;if filename specified...
  72.     lea.l    Pic0FlNm,a0    ;default ILBM0
  73. .ld0    movea.l    ([DIAdr.l],TCS_DI_CSAdr.w),a1 ;directly to back
  74.     move.l    #SCRWD*SCRHT,d0    ;playfield screen buffer
  75.     CALLTCS    LdILBM    ;load it
  76.     cmpi.l    #TCS_PE_OK,d0    ;success?
  77.     blo.s    .fail    ;if not...
  78.  
  79.     move.b    (TCS_II_RGBxMode.w,d0.l),d2 ;get ILBM0's RGBx mode
  80.     movea.l    d0,a0    ;free all the memory allocated
  81.     CALLTCS    UnLdILBM    ;for the ILBMInfo structure
  82.     movea.l    DIAdr,a0
  83.     move.b    d2,d0    ;RGBx mode
  84.     move.w    #DSPLBRTNS,d1
  85.     CALLTCS    SetRGBx    ;set back playfield palette
  86.  
  87. *******************************************************************************
  88. * front playfield
  89.  
  90.     movea.l    CmdLnArgs+4,a0    ;ILBM1 filename address
  91.     tst.l    a0
  92.     bne.s    .ld1    ;if filename specified...
  93.     lea.l    Pic1FlNm,a0    ;default ILBM1
  94. .ld1    movea.l    ([FPfldDI.l],TCS_DI_CSAdr.w),a1 ;directly to front
  95.     move.l    #SCRWD*SCRHT,d0    ;playfield screen buffer
  96.     CALLTCS    LdILBM    ;load it
  97.     cmpi.l    #TCS_PE_OK,d0    ;success?
  98.     blo.s    .fail    ;if not...
  99.  
  100.     move.b    (TCS_II_RGBxMode.w,d0.l),d2 ;get ILBM1's RGBx mode
  101.     movea.l    d0,a0    ;free all the memory allocated
  102.     CALLTCS    UnLdILBM    ;for the ILBMInfo structure
  103.     movea.l    FPfldDI,a0
  104.     move.b    d2,d0    ;RGBx mode
  105.     move.w    #DSPLBRTNS,d1
  106.     CALLTCS    SetRGBx    ;set front playfield palette
  107.  
  108. *******************************************************************************
  109. * picture for Dual Cross Playfield
  110.  
  111.     movea.l    CmdLnArgs+8,a0    ;ILBM2 filename address
  112.     tst.l    a0
  113.     bne.s    .ld2    ;if filename specified...
  114.     lea.l    Pic2FlNm,a0    ;default ILBM2
  115. .ld2    suba.l    a1,a1
  116.     CALLTCS    LdILBM    ;load it
  117.     cmpi.l    #TCS_PE_OK,d0    ;success?
  118.     blo.s    .fail    ;if not...
  119.     move.l    d0,ILBM2    ;store ILBMInfo structure pointer
  120.  
  121. *******************************************************************************
  122. * Cross Playfield / exit
  123.  
  124.     movea.l    DIAdr,a0    ;back playfield DI
  125.     movea.l    FPfldDI,a1    ;front playfield DI
  126.     CALLTCS    EnbXPfld    ;enable Cross Playfield
  127.  
  128.     move.w    #0,ccr    ;OK!
  129.     rts
  130. .fail    move.w    #4,ccr    ;signal error
  131.     rts
  132.  
  133.  
  134.  
  135. *******************************************************************************
  136. * main
  137. *******************************************************************************
  138.  
  139. _PrgMain    movea.l    FPfldDI,a0
  140.     CALLTCS    ShwDspl    ;show front playfield, too
  141.     movea.l    DIAdr,a0    ;render back playfield
  142.     CALLTCS    CPUFRPass0    ;to make pixels visible
  143.     movea.l    FPfldDI,a0    ;render front playfield
  144.     CALLTCS    CPUFRPass0    ;to make pixels visible
  145.  
  146. *******************************************************************************
  147. * first cross-fade: the front playfield disappears behind the back playfield
  148.  
  149.     movea.l    FPfldDI,a2
  150.     move.w    #256,d2    ;opacity at beginning (max)
  151. .XFade0    WTRSTLN    DSPLY0    ;wait for Copper to write the palette
  152.     movea.l    a2,a0    ;our display
  153.     move.w    d2,d0
  154.     CALLTCS    SetFPfldOpct    ;change opacity
  155.     btst.b    #6,$bfe001    ;exit if LMB
  156.     dbeq    d2,.XFade0    ;decrease opacity and repeat other 256 times
  157.  
  158. *******************************************************************************
  159. * second cross-fade: a new picture is written to the front playfield (still
  160. * hidden) and then shown with a cross-fade-in (Dual mode)
  161.  
  162.     movea.l    ([ILBM2.l],TCS_II_GfxAdr.w),a0 ;ILBM2 gfx data adr
  163.     movea.l    (TCS_DI_CSAdr,a2),a1    ;front playfield screen address
  164.     move.w    #SCRWD*SCRHT/4-1,d0    ;copy ILBM2
  165. .CpyPxl    move.l    (a0)+,(a1)+    ;to front playfield
  166.     dbra    d0,.CpyPxl    ;screen
  167.  
  168.     movea.l    a2,a0    ;render front playfield
  169.     CALLTCS    CPUFRPass0    ;to make pixels visible
  170.  
  171.     movea.l    a2,a0    ;our display
  172.     moveq.l    #15,d0    ;RGBx transparent color
  173.     CALLTCS    EnbDXPfld    ;enable Dual modality
  174.  
  175.     move.w    #256,d2    ;counter
  176. .XFade1    WTRSTLN    DSPLY0    ;wait for Copper to write the palette
  177.     movea.l    a2,a0    ;our display
  178.     move.w    #256,d0    ;calculate new
  179.     sub.w    d2,d0    ;opacity
  180.     CALLTCS    SetFPfldOpct    ;change opacity
  181.     btst.b    #6,$bfe001    ;exit if LMB
  182.     dbeq    d2,.XFade1    ;repeat other 256 times
  183.  
  184. *******************************************************************************
  185. * first fade: the front playfield is faded out, while the back playfield
  186. * remains visible
  187.  
  188.     move.b    (TCS_DI_VdoMode+3,a2),d3    ;get RGBx mode
  189.     move.w    #256,d2    ;brightness at beginning (max)
  190. .FadeOut0    WTRSTLN    DSPLY0    ;wait for Copper to write the palette
  191.     movea.l    a2,a0    ;our display
  192.     move.b    d3,d0    ;RGBx mode
  193.     move.w    d2,d1    ;brightness
  194.     CALLTCS    SetRGBx    ;change palette
  195.     btst.b    #6,$bfe001    ;exit if LMB
  196.     dbeq    d2,.FadeOut0    ;decrease brightness and repeat other 256 times
  197.  
  198. *******************************************************************************
  199. * second fade: the front playfield is faded in, while the back playfield is
  200. * still visible
  201.  
  202.     move.b    (TCS_DI_VdoMode+3,a2),d3    ;get RGBx mode
  203.     moveq.l    #0,d2    ;brightness at beginning (min)
  204. .FadeIn    WTRSTLN    DSPLY0    ;wait for Copper to write the palette
  205.     movea.l    a2,a0    ;our display
  206.     move.b    d3,d0    ;RGBx mode
  207.     move.w    d2,d1    ;brightness
  208.     CALLTCS    SetRGBx    ;change palette
  209.     addq.w    #1,d2    ;increase brightness
  210.     btst.b    #6,$bfe001
  211.     beq.s    .FadeOut    ;if LMB...
  212.     cmpi.w    #256,d2
  213.     bls.s    .FadeIn    ;repeat other 256 times
  214.  
  215. *******************************************************************************
  216. * third cross-fade: the front playfield is half-cross-faded-out
  217.  
  218.     movea.l    FPfldDI,a2    ;front playfield DI structure pointer
  219.     move.w    #128,d2    ;counter
  220. .XFade3    WTRSTLN    DSPLY0    ;wait for Copper to write the palette
  221.     movea.l    a2,a0    ;our display
  222.     move.w    d2,d0    ;calculate
  223.     addi.w    #128,d0    ;new opacity
  224.     CALLTCS    SetFPfldOpct    ;change opacity
  225.     btst.b    #6,$bfe001    ;exit if LMB
  226.     dbeq    d2,.XFade3    ;decrease opacity and repeat other 128 times
  227.  
  228. *******************************************************************************
  229. * third fade: the back playfield is faded out, while the front playfield
  230. * remains visible
  231.  
  232. .FadeOut    movea.l    DIAdr,a2    ;back playfield DI structure pointer
  233.     move.b    (TCS_DI_VdoMode+3,a2),d3    ;get RGBx mode
  234.     move.w    #256,d2    ;brightness at beginning (max)
  235. .FadeOut1    WTRSTLN    DSPLY0    ;wait for Copper to write the palette
  236.     movea.l    a2,a0    ;our display
  237.     move.b    d3,d0    ;RGBx mode
  238.     move.w    d2,d1    ;brightness
  239.     CALLTCS    SetRGBx    ;change palette
  240.     btst.b    #6,$bfe001    ;exit if LMB
  241.     dbeq    d2,.FadeOut1    ;decrease brightness and repeat other 256 times
  242.  
  243. *******************************************************************************
  244. * fourth cross-fade: the front playfield is half-cross-faded-in
  245.  
  246.     movea.l    FPfldDI,a2    ;front playfield DI structure pointer
  247.     move.w    #128,d2    ;counter
  248. .XFade4    WTRSTLN    DSPLY0    ;wait for Copper to write the palette
  249.     movea.l    a2,a0    ;our display
  250.     move.w    #256,d0    ;calculate
  251.     sub.w    d2,d0    ;new opacity
  252.     CALLTCS    SetFPfldOpct    ;change opacity
  253.     btst.b    #6,$bfe001    ;exit if LMB
  254.     dbeq    d2,.XFade4    ;decrease opacity and repeat other 128 times
  255.  
  256. *******************************************************************************
  257. * final fade: the front playfield is faded out, too
  258.  
  259.     movea.l    FPfldDI,a2    ;front playfield DI structure pointer
  260.     move.b    (TCS_DI_VdoMode+3,a2),d3    ;get RGBx mode
  261.     move.w    #256,d2    ;brightness at beginning (max)
  262. .FadeOut2    WTRSTLN    DSPLY0    ;wait for Copper to write the palette
  263.     movea.l    a2,a0    ;our display
  264.     move.b    d3,d0    ;RGBx mode
  265.     move.w    d2,d1    ;brightness
  266.     CALLTCS    SetRGBx    ;change palette
  267.     btst.b    #6,$bfe001    ;exit if LMB
  268.     dbeq    d2,.FadeOut2    ;decrease brightness and repeat other 256 times
  269.  
  270. *******************************************************************************
  271. * end
  272.  
  273. .exit    movea.l    FPfldDI,a0    ;hide front playfield,
  274.     CALLTCS    HideDspl    ;otherwise it can't be freed!
  275.     rts
  276.  
  277.  
  278.  
  279. *******************************************************************************
  280. * cleanup
  281. *******************************************************************************
  282.  
  283. _PrgClnUp    movea.l    ILBM2,a0    ;free all the memory
  284.     CALLTCS    UnLdILBM    ;allocated for ILBM2
  285.     movea.l    DIAdr,a0
  286.     CALLTCS    DsbXPfld    ;disable Cross Playfield
  287.     movea.l    FPfldDI,a0    ;free all the memory allocated
  288.     CALLTCS    FreeDspl    ;for the front playfield
  289.     rts
  290.  
  291.  
  292.  
  293. *******************************************************************************
  294. * data
  295. *******************************************************************************
  296.  
  297.     include    /includes/dat.i
  298.  
  299.     cnop    0,4
  300. FPfldDI    dc.l    0    ;front playfield DI structure address
  301. ILBM2    dc.l    0    ;ILMBInfo structure pointer
  302. tmplt    dc.b    "ILBM0/K,ILBM1/K,ILBM2/K",0 ;template for ReadArgs()
  303. Pic0FlNm    dc.b    "/pix/TM_rgbm.iff",0    ;default ILBM #0 (back playfield)
  304. Pic1FlNm    dc.b    "/pix/Alphonse_rgbh.iff",0 ;default ILBM #1 (front playfield)
  305. Pic2FlNm    dc.b    "/pix/DXP_rgbh.iff",0    ;default ILBM #2 (for Dual Cross Playfield)
  306.